<template >
  <div class="post-list" v-if="list">
    <article v-for="post in list" v-bind:key="post.id" class="card mb-3 shadow-sm">
      <div class="card-body">
        <h4>{{post.title}}</h4>
        <div class="row my-3 align-items-center">
          <div v-if="post.imgurl" class="col-4">
            <img :src="post.imgurl" :alt="post.title" class="rounded-lg w-100">
          </div>
          <p :class="{'col-8': post.imgurl}" class="text-muted">{{post.content}}</p>
        </div>
        <span class="text-muted">{{post.createdAt}}</span>
      </div>
    </article>
  </div>
</template>

<script lang='ts'>
import {defineComponent, PropType} from 'vue'
import {testPostsData,PostProps} from '@/testDate/ColumnDate/index'

export default defineComponent({
    props: {
        list: {
            require : true,
            type: Array as PropType<PostProps[]>
        },
        currentId: {
          require: true,
          type: Number
        }
    },
    setup(props) {
      console.log('列表：',props.list);
      console.log('列表currentId：',props.currentId);
     const lists = testPostsData.filter(c=> c.columnId == props.currentId)
      return {
        lists
      }
    }

})
</script>

<style>

</style>